﻿@model thailandProject.Models.Pair<thailandProject.Models.Pair<List<thailandProject.Models.PAYMENT>, List<thailandProject.Models.RESERVATION>>, int >

@{
    ViewBag.Title = "View Client Payments";
}


<div id="Wrapper2">
    <div id="content_header">
        <div id="headerimage">
        </div>
        <div id="theheader">@ViewBag.Header</div>
    </div>
    <!-- Left Column begins here -->
    <aside id="sidebar-wrapper">
        <nav class="sidebar">
            <!-- CONTENT GOES HERE -->
            <div style="float:left; width:100%; margin:10px 0px 20px 0px;">
            <div class="viewclientrow" style="color:#777777; font-weight:bold;">
            PAYMENT HISTORY
            </div>
            @if (Model.value1.value1.Count > 0)
            {
                int i = 0;
                <table cellspacing="0" cellpadding="5" id="searchclienttable">
                    <tr id="searchclienttoprow">
                        <th class="searchclientcols20">
                            Apartment
                        </th>
                        <th class="searchclientcols20">
                            Date
                        </th>
                        <th class="searchclientcols20">
                            Amount
                        </th>
                        <th class="searchclientcols20">
                            Type
                        </th>
                        <th class="searchclientcols20">
                            Is Deposit
                        </th>
                        <th>
                            <!-- View Column -->
                        </th>
                    </tr>

                @foreach(thailandProject.Models.PAYMENT p in Model.value1.value1)
                {
                    if (thailandProject.Models.UtilMethods.isOdd(i))
                    {
                        <tr style="background:url('/images/transblack1.png') repeat scroll 0 0 transparent;" class="searchclientrow">
                            <td style="border-bottom:1px dotted #cccccc; font-weight:bold;">
                                @Html.DisplayFor(modelItem => p.RESERVATION.PROPERTY.propName)
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @p.RESERVATION.resStartDate.ToShortDateString()
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                
                                @Html.DisplayFor(modelItem => p.paymentAmount)
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @{
                                    string type = p.paymentType ?? "";
                                    type = type.Trim();
                                    if (type == "PayPal" || type == "Pay Pal" || type == "paypal")
                                    {
                                        <img src="../../images/paypal_icon_small.png" alt="paypal" />
                                    }
                                    else if (type == "Credit Card" || type == "CreditCard" || type == "credit card")
                                    {
                                        <img src="../../images/creditcard_icon_small.png" alt="credit card" />
                                    }
                                    else if (type == "Cash" || type == "cash")
                                    {
                                        <img src="../../images/cash_icon_small.png" alt="cash" />
                                    }
                                    else
                                    {
                                        @Html.DisplayFor(modelItem => p.paymentType)
                                    }
                                 }
                                
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @if (p.paymentIsDeposit)
                                {
                                    <span style="color:green">YES</span>
                                }
                                else
                                {
                                    <span>NO</span>
                                }
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @{
                                    string view_link = "ViewClientPayment?paymentId=" + p.paymentID;
                                    <a href="@view_link"><img src="../../images/viewclient_small_long.png" alt="view" /></a>
                                 }
                            </td>
                        </tr>
                    }
                    // if not odd row, then show a slight color change for better view
                    else
                    {
                        <tr class="searchclientrow">
                        
                            <td style="border-bottom:1px dotted #cccccc; font-weight:bold;">
                                @Html.DisplayFor(modelItem => p.RESERVATION.PROPERTY.propName)
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @p.RESERVATION.resStartDate.ToShortDateString()
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @Html.DisplayFor(modelItem => p.paymentAmount)
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @{
                                    string type = p.paymentType ?? "";
                                    type = type.Trim();
                                    if (type == "PayPal" || type == "Pay Pal" || type == "paypal")
                                    {
                                                    <img src="../../images/paypal_icon_small.png" alt="paypal" />
                                    }
                                    else if (type == "Credit Card" || type == "CreditCard" || type == "credit card")
                                    {
                                                    <img src="../../images/creditcard_icon_small.png" alt="credit card" />
                                    }
                                    else if (type == "Cash" || type == "cash")
                                    {
                                                    <img src="../../images/cash_icon_small.png" alt="cash" />
                                    }
                                    else if (type == "Western Union" || type == "WesternUnion" || type == "western union")
                                    {
                                                    <img style="height:26px" src="../../images/WU.jpg" alt="western union" />
                                    }
                                    else if (type == "Wire Transfer" || type == "WireTransfer" || type == "wire transfer")
                                    {
                                                    <img style="height:26px" src="../../images/wire.jpg" alt="wire transfer" />
                                    }
                                    else
                                    {
                                                    @Html.DisplayFor(modelItem => p.paymentType)
                                    }
                                 }
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @if (p.paymentIsDeposit)
                                {
                                    <span style="color:green">YES</span>
                                }
                                else
                                {
                                    <span>NO</span>
                                }
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @{
                                string view_link = "ViewClientPayment?paymentId=" + p.paymentID;
                                    <a href="@view_link"><img src="../../images/viewclient_small_long.png" alt="view" /></a>
                                 }
                            </td>
                        </tr>   
                    }
                    i++;
                }
             </table>
            }
            else
            {
                @:No payments found.
            }
            </div>
            <div style="float:left; width:100%; margin:10px 0px 10px 0px;">
            @Html.ActionLink("Back", "ViewClient", new { clientId = Model.value2 })
            </div>
        </nav>
    </aside>
    <!-- Right column begins here -->
    <article id="contents">
        This page shows the client's payment history.
        <br /><br />
        <strong>Payment history</strong> shows all previously entered payments that a client has made. To view details about a particular payment, 
        press the page icon at the end of a row. You can also edit details about the payment on the following page.
    </article>
    <!-- Right column ends here -->
</div>
<!-- Div wrapper2 ends here -->


<script type = "text/javascript">
    $(function () {
        $(".datepicker").datepicker();
    });
</script>